import Storage from "@/utils/storage";




const Wxlogin = () => {
    return new Promise((resolve, reject) => {
        uni.login({
            force: true,
            success: async (res) => {
                let userInfo;
                const code = res.code;
                userInfo = {
                    code
                }
                const apiRes = await weiXinLoginApi(code, "wx31f89360ca7a11d0");
                if(apiRes.data){
                    Storage.setStorage("userId", apiRes.data.user_id);
                    userInfo={
                        ...userInfo,
                        userId : apiRes.data.user_id
                    }
                    resolve(userInfo)
                }else{
                    reject(false)
                    return
                }
            },
            fail(res) {
                console.log(`login 调用失败`);
            },
            complete(res) {
                console.log("login 调用完成");
            },
        });
    });
};




export {

    Wxlogin
}